# import onnxruntime


# class UvPredict:
#     def __init__(self, onnx_path: str):
#         self.preprocess_op = create_operators(pre_process_list)
#         post_process_list = [
#             {"ClasTopk":
#                 {
#                     "topk": 2,
#                     "class_ids": ["0", "90", "180", "270"]
#                 }
#             }
#         ]
#         self.postprocess_op = create_operators(post_process_list)
#         self.session = onnxruntime.InferenceSession(onnx_path)
#         self.thresh = 0.8
#
#     def _onnx_predict(self, img):
#         input_name = self.session.get_inputs()[0].name
#         output_name = self.session.get_outputs()[0].name
#         pred = self.session.run([output_name], {input_name: img})[0]
#         return pred
#
#     def predict(self, img):
#         data = {"image": img.copy()}
#         data = transform(data, self.preprocess_op)
#         predict_data = np.expand_dims(data["image"], axis=0)
#         pred = self._onnx_predict(predict_data)
#         post_process_result = transform({"cls_pred": pred[0]}, self.postprocess_op)
#         logger.info(f"TextImagePredict = {post_process_result}")
#         return post_process_result
#
#     def __call__(self, img):
#         post_process_result = self.predict(img)
#         angle = post_process_result["label_names"][0]
#         cv_rotate_code = {
#             "90": cv2.ROTATE_90_COUNTERCLOCKWISE,
#             "180": cv2.ROTATE_180,
#             "270": cv2.ROTATE_90_CLOCKWISE,
#         }
#         if angle in cv_rotate_code:
#             img = cv2.rotate(img, cv_rotate_code[angle])
#         return img